package cn.xuyang520.tyim.sys.domain;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by admin on 2017/4/2.
 */
public interface TySysUserRepository extends JpaRepository<TySysUser, String> {

    TySysUser findByTbUsername(String tbUsername);

    TySysUser findByTbUsernameAndTbPassword(String tbUsername, String tbPassword);

    @Override
    @Query(value = "SELECT\n" +
            "`user`.tb_id,\n" +
            "`user`.tb_username,\n" +
            "`user`.tb_name,\n" +
            "`user`.tb_password,\n" +
            "`user`.tb_creat_time,\n" +
            "`user`.tb_group_code,\n" +
            "`group`.tb_name `tb_group_name`,\n" +
            "`user`.tb_last_login_time\n" +
            "FROM\n" +
            "ty_sys_user AS `user`\n" +
            "LEFT JOIN ty_sys_group AS `group` ON `user`.tb_group_code = `group`.tb_code", nativeQuery = true)
    List<TySysUser> findAll();





}
